<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>郑文祥的个人博客</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/client/css/style.css">
</head>

<body class="bg-light">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <a class="navbar-brand" href="/">
        <img src="/client/img/logo.png" width="50" height="50" class="animate-rot" alt="">
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" href="/">首页</a>
            </li>
            <%for(let i = 0;i < categories.length; i++){%>
            <li class="nav-item">
                <a class="nav-link" href="/article/category/<%=categories[i].id%>"><%=categories[i].name%></a>
            </li>
            <%}%>
        </ul>
        <form class="form-inline my-2 my-lg-0 ml-5" method="get" action='/article/search'>
            <input class="form-control mr-sm-2" name="keyword" type="search" placeholder="请输入关键词...">
            <button class="btn btn-outline-success my-2 my-sm-0" type="submit">搜索</button>
        </form>
        <ul class="navbar-nav ml-auto login-nav">
            <%if(userInfo){%>
                <li class="nav-item to-admin">
                    <a href="/admin">进入博客后台管理系统</a>
                </li>
                <li class="nav-item dropdown" style="margin-left:20px;">
                    <a class="nav-link dropdown-toggle" href="javascript:;" id="navbarDropdown" data-toggle="dropdown">
                        <%=userInfo.username%>
                    </a>
                    <div class="dropdown-menu">
                        <a class="dropdown-item" href="/logout">退出</a>
                    </div>
                </li>
            <%}else{%>
                <li class="nav-item">
                    <a href="/login" class="nav-link">登录</a>
                </li>
            <%}%>
        </ul>
    </div>
</nav>